#include "buttongroup.h"
#include "ui_buttongroup.h"
#include<QtDebug>
ButtonGroup::ButtonGroup(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ButtonGroup)
{
    ui->setupUi(this);
}

ButtonGroup::~ButtonGroup()
{
    delete ui;
}

void ButtonGroup::initButton()
{
    ui->start->setImage(":/images/images/start-1.png",":/images/images/start-3.png",":/images/images/start-2.png");

    ui->playCard->setImage(":/images/images/chupai_btn-1.png",":/images/images/chupai_btn-3.png",":/images/images/chupai_btn-2.png");
    ui->playcard1->setImage(":/images/images/chupai_btn-1.png",":/images/images/chupai_btn-3.png",":/images/images/chupai_btn-2.png");

    ui->pass->setImage(":/images/images/pass_btn-1.png",":/images/images/pass_btn-3.png",":/images/images/pass_btn-2.png");

    ui->giveup->setImage(":/images/images/buqiang-1.png",":/images/images/buqiang-3.png",":/images/images/buqiang-2.png");
    ui->onescore->setImage(":/images/images/1fen-1.png",":/images/images/1fen-3.png",":/images/images/1fen-2.png");
    ui->twoscore->setImage(":/images/images/2fen-1.png",":/images/images/2fen-3.png",":/images/images/2fen-2.png");
    ui->threescore->setImage(":/images/images/3fen-1.png",":/images/images/3fen-3.png",":/images/images/3fen-2.png");

    QVector<MyButton*> btns;
    btns<<ui->start<<ui->playCard<<ui->playcard1<<ui->pass
         <<ui->giveup<<ui->onescore<<ui->twoscore<<ui->threescore;
    for(int i =0 ;i<btns.size();i++)
    {
        btns[i]->setFixedSize(90,45);
    }

    connect(ui->start,&MyButton::clicked,this,&ButtonGroup::startGame);
    connect(ui->playCard,&MyButton::clicked,this,&ButtonGroup::playHand);
    connect(ui->playcard1,&MyButton::clicked,this,&ButtonGroup::playHand);
    connect(ui->pass,&MyButton::clicked,this,&ButtonGroup::pass);
    connect(ui->giveup,&MyButton::clicked,this,[=]()
        {
            qDebug()<<"betpoint(0)";
            emit betPoint(0);
        });
    connect(ui->onescore,&MyButton::clicked,this,[=]()
        {
            qDebug()<<"betpoint(1)";
            emit betPoint(1);
        });
    connect(ui->twoscore,&MyButton::clicked,this,[=]()
        {
            qDebug()<<"betpoint(2)";
            emit betPoint(2);
        });
    connect(ui->threescore,&MyButton::clicked,this,[=]()
        {
            qDebug()<<"betpoint(3)";
            emit betPoint(3);
        });

}

void ButtonGroup::selectPage(Panel type,int bet)
{
    ui->stackedWidget->setCurrentIndex(type);
    if(type !=CallLord)
    {
        return;
    }
    if(bet == 0)
    {
        ui->onescore->setVisible(true);
        ui->twoscore->setVisible(true);
        ui->threescore->setVisible(true);
    }else if(bet == 1)
    {
        ui->onescore->setVisible(false);
        ui->twoscore->setVisible(true);
        ui->threescore->setVisible(true);
    }else if(bet == 2)
    {
        ui->onescore->setVisible(false);
        ui->twoscore->setVisible(false);
        ui->threescore->setVisible(true);
    }
}
